var Md5 = require('../../utils/md5.js');
var timeSecond = Math.floor(Date.now() * 0.001);  //获取时间戳: 
var SignInfoData = Md5.hexMD5(timeSecond + 'nativetalk')//md5加密;
const app = getApp();
var httpNativetalk = app.globalData.httpNativetalk;
var httpWeike = app.globalData.httpWeike;
Page({
  data: {    
    littleType: ['听说读写', '新概念', '英语口语', '外教1V1', '四六级', 'BEC'],
    imgUrl: 'http://file.waijiaojun.com/waijiaojun/icon',
  },
  onLoad:function(e){
  
  },
  onShow: function () {
    var that = this;
    wx.request({
      url: httpNativetalk + '/app/9/course/index',
      data: {
        // "cate_id": e.cateId,
        imgUrl: 'http://file.waijiaojun.com/waijiaojun/icon',
      },
      header: {//请求头
        "Timestamp": timeSecond,
        "SignInfo": SignInfoData,
        "content-Type": "application/json",
        "client_type": "3",
        "version": 15,
        "token": '',
      },
      method: 'POST',
      success: function (res) {
        var courseCardAreaData = res.data.obj.course;
        // console.log(res.data.obj.course);
        if (courseCardAreaData == null) {
          console.log("数据为空")
        } else {         
          var courseCard = [];
          for (var i = 0; i < courseCardAreaData.length; i++) {
             courseCardAreaData[i].show_arr = courseCardAreaData[i].tsNtCourseInfoIndices.slice(0,2);
             courseCardAreaData[i].show_list = courseCardAreaData[i].tsNtCourseInfoIndices.slice(2);            
          }
          that.setData({
            courseCardAreaData: courseCardAreaData
          })        
        };
      },
      fail: function (res) { },
      complete: function (res) { },
    })
    wx.showShareMenu({
      withShareTicket: true,

    })
  },
  topTypeDetailFun: function (e) {
    // console.log(e.currentTarget.dataset.idx)
    var cateIds= e.currentTarget.dataset.idx;
    var titleData = e.currentTarget.dataset.titles;
    wx.navigateTo({
      url: '/pages/selectClassTopDetail/selectClassTopDetail?cateId=' + cateIds,
    });
    wx.setNavigationBarTitle({
      title: titleData,
    })
  },  
  toClassDetailFun: function (e) {
    var classIds=e.currentTarget.dataset.idx;
    var titleData = e.currentTarget.dataset.titles;
    wx.navigateTo({
      url: '/pages/classDetail/classDetail?classId=' + classIds,
    });
    wx.setNavigationBarTitle({
      title: titleData,
    })
  }
})